package com.mjw.tender.execption;

import com.mjw.tender.dto.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
@Slf4j
public class BlogWebExceptionHandle {

    @ExceptionHandler(Exception.class)
    public ResponseEntity<ResponseResult> handleExecption(HttpServletRequest request, Exception ex){
        log.error(ex.getMessage());
        ex.printStackTrace();
        return new ResponseEntity(
                new ResponseResult(ResponseResult.CodeStatus.FAIL,"未知异常"), HttpStatus.OK);
    }
}
